import store from "@/store";
export default {
  mounted(el, binding) {
    const { value } = binding;
    const userRoles = store.getters.roles;
    const permissions = userRoles; // 实际应从store获取
    // console.log("[权限校验] 所需权限:", binding.value);
    // console.log("[权限校验] 用户现有权限:", permissions);
    if (value && Array.isArray(value)) {
      if (!value.some((perm) => permissions.includes(perm))) {
        el.parentNode?.removeChild(el); // 更安全的DOM移除方式
      }
    } else {
      console.error(
        "v-permission指令需要数组参数，例如 v-permission=\"['admin']\""
      );
    }
  }
};
